package actions;

import bin.Mud;
import items.Item;

public class EquipDecider {
    private Mud mudWindow;

    public EquipDecider(Mud mudWindow) {
        this.mudWindow = mudWindow;
    }

    public boolean isEquip() {
        return (mudWindow.getCommand().startsWith("EQUIP"));
    }

    public boolean isUnequip() {
        return (mudWindow.getCommand().startsWith("UNEQUIP"));
    }

    public boolean isShowEquip() {
        return (mudWindow.getCommand().equals("EQUIP") || mudWindow.getCommand().equals("EQ"));
    }

    public Item itemToEquip() {
        String itemString = mudWindow.getCommand().replaceFirst("EQUIP ", "");
        for (Item item : mudWindow.getPlayer().getPlayerInventory(null)) {
            if (item.getTitle().equalsIgnoreCase(itemString) || item.getShortName().equalsIgnoreCase(itemString)) {
                return item;
            }
        }
        return null;
    }

    public Item itemToUnequip() {
        String itemString = mudWindow.getCommand().replaceFirst("UNEQUIP ", "");
        for (Item item : mudWindow.getPlayer().getPlayerEquipment()) {
            if (item.getTitle().equalsIgnoreCase(itemString) || item.getShortName().equalsIgnoreCase(itemString)) {
                return item;
            }
        }
        return null;
    }
}